<?php include PATH_TPL."/admin/tpl.header.phtml"?>
<div class="main-container inner">
    <div class="main-content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12 bg">
                    <ol class="breadcrumb">
                        <li class="active">
                            <i class="fa  fa-fw fa-reorder"></i>修改课程系列
                        </li>
                    </ol>
                </div>
            </div>

            <div id="page-wrapper">
                <div class="container-fluid col-md-7 col-sx-12">
                    <form action="/admin_courseseries/edit" method="post" enctype="multipart/from-data">
                        <div class="form-group ">
                            <label for="title">系列课程名称</label>
                            <input type="text" placeholder="输入系列课程名称" id="title" class="form-control" name="title" value="<?=$tCSRow['title']?>">
                        </div>
                        <div class="form-group">
                            <label for="img">系列课程缩略图</label>
                            <input type="file" id="file_input" name="img">
                            <input type="hidden" name="img_new" value="<?=$tCSRow['img']?>">
                        </div>
                        <input type='hidden' value='<?=$tId?>' name='id'/>
                        <button class="btn btn-primary demo_2" type="button" id="submit">修改</button>
                    </form>
                </div>
                <div class="container-fluid col-md-5">
                    <div class="images text-center" id="img_view">
                    <?if(!empty($tCSRow['img'])){?><img src='<?=$tCSRow['img']?>' width='400px' /><?}?>
                    </div>
                </div>
            </div>
            <!--课程列表开始-->
                  &nbsp;&nbsp;&nbsp;&nbsp; <label><strong>课程列表</strong></label>
                <div class="row">
                    <form method="get" action="/admin_courseseries/edit?id=<?=$tId?>">
                    <input type='hidden' value='<?=$tId?>' name='id' />            
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="btn btn-success" id="add" style="height:25px;width:96px;line-height:10px;" href="/admin_courseseries/addcourse?cs_id=<?=$tId?>">添加课程</a>
                     <input type="text" placeholder="请输入课程名称关键字" value="<?=$pKeyWord?>" name="keyword" class="form-controll" style="width:150px;">
                    <span clas="input-group-btn">
                        <button class="btn btn-default" id="search"><i class="fa fa-search"></i></button>
                    </span>
                    </form>
                </div>
                <div class="panel-body text-center">
                    <table class="table table-hover text-center" id="sample-table-1">
                        <thead>
                            <tr>
                                <td>编号</td>
                                <td>课程标题</td>
                                <td>课程类别</td>
                                <td>封面图片</td>
                                <td>讲师</td>
                                <td>课程简介</td>
                                <td>创建时间</td>
                                <td>播放次数</td>
                            </tr>
                        </thead>
                        <?foreach($tDatas as $tRow){?>
                            <tr>
                                <td><?=$tRow['id']?></td>
                                <td><?=$tRow['title']?></td>
                                <td><?=$tRow['cate_name']?></td>
                                <td class="center slt"><img src="<?=$tRow['img']?>" alt="image"/></td>
                                <td><?=$tRow['lecturer_name']?></td>
                                <td><?=$tRow['descriptions']?></td>
                                <td><?=date('Y-m-d H:i',$tRow['created'])?></td>
                                <td><?=$tRow['complete']?></td>

                            </tr>
                        <?}?>
                        <input type="text" class="id hidden" name="id" value="<?=$pId?>">

                    </table>
                    <?=$tShow?>
                </div>
            </div>
                </div>
            </div>
        </div>
        <div class="subviews">
            <div class="subviews-container"></div>
        </div>

    <!-- end: PAGE -->
</div>
<!-- end: MAIN CONTAINER -->
<script type="text/javascript" src="/plugins/jquery-ui-1.11.4/jquery-ui.min.js"></script>
<script>
$(function(){
    //提交    
    var options={
        beforeSubmit : showRequest,    // 提交前的回调函数
        success : showResponse,    // 提交后的回调函数
        dataType : "json",    // html（默认）、xml、script、json接受服务器端返回的类型
        timeout : 3000    // 限制请求的时间，当请求大于3秒后，跳出请求
    }
    function showRequest(formData, jqForm, options){
        return true;
    }
    function showResponse(responseText,statusText){
            cg_alert_edit(responseText,'/admin_courseseries','/admin_courseseries/edit?id=<?=$tId?>');
    }

    $('#submit').click(function() {
        $('form').ajaxSubmit(options);
        return false;

    });
    $('#series').click(function(){
        $(this).addClass('hidden');    
        $('#addcourse').removeClass('hidden');
    });
});

//FileReader显示素略图
var result = document.getElementById("img_view");
var input = document.getElementById("file_input");
if(typeof FileReader==='undefined'){
    result.innerHTML = "抱歉，你的浏览器不支持 FileReader";
    input.setAttribute('disabled','disabled');
}else{
    input.addEventListener('change',readFile,false);
}
function readFile(){
    var file = this.files[0];
    if(!/image\/\w+/.test(file.type)){
        alert("文件必须为图片！");
        return false;
    }
    var reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = function(e){
        result.innerHTML = '<img src="'+this.result+'" alt="" width="400px"/>'
    }
}
</script>
<?php include PATH_TPL."/admin/tpl.footer.phtml"?>
